package com.bishe.supermarket.service;

import com.bishe.supermarket.mapper.ProfitMapper;
import com.bishe.supermarket.pojo.Profit;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class FinanceService {

    @Autowired
    ProfitMapper profitMapper;

    public List<Profit> selectProfit(){

        List<Profit> list = profitMapper.selectAll();

        for (Profit p:list) {
            System.out.println("id"+p.getCommodityId());
        }

        return list;
    }
    public int totalProfit(){
        List<Profit> list = profitMapper.selectAll();
        int total = 0;
        for (Profit p:list) {
//            System.out.println("id"+p.getCommodityId());
           total  = total + p.getCommodityProfit()*p.getCommoditySalenum();
        }

        return total;
    }
}
